import {
  NestModule,
  Module,
  MiddlewareConsumer,
  RequestMethod,
} from '@nestjs/common';
import { UsersService } from './users.service';
import { UsersController } from './users.controller';
import { Logger } from 'src/middleware';
import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from './entities/user.entity';

@Module({
  imports: [TypeOrmModule.forFeature([User])],
  controllers: [UsersController],
  providers: [UsersService],
  exports: [UsersService],
})
export class UsersModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    // 配置拦截
    // consumer.apply(Logger).forRoutes({path:'/users',method:RequestMethod.GET})
    // 全部拦截
    // consumer.apply(Logger).forRoutes(UsersController)
  }
}
